package com.elinshaw.pattern.event;

public class InputEventHandler implements Channel<InputEvent> {

    private final EventDispatcher eventDispatcher;

    public InputEventHandler(EventDispatcher eventDispatcher) {
        this.eventDispatcher = eventDispatcher;
    }

    @Override
    public void dispatch(InputEvent message) {
        System.out.println(message.getX() + ":" + message.getY());
        int result = message.getX() + message.getY();
        eventDispatcher.dispatch(new ResultEvent(result));
    }

}
